package com.nwpusp.display.views.components;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import android.view.View;

import com.example.petssports.R;
import com.nwpusp.display.GlobalVar;

public class GameProcessBarHeader extends View{
	
	public Bitmap bar_header;
	public static float init_x;
	public static float init_y;
	public float x;
	public float y;
	public float scale;
	public int headerIndex;
	public float width;
	public float height;
	public int index;
	
	
	public GameProcessBarHeader(Context view,float newHeight,int index){
		super(view);
		this.height = newHeight;
		this.index = index;
		getBitmapSource();
		bar_header = GlobalVar.VerticalScaleFixHeight(bar_header,height);
		width = bar_header.getWidth();
	}
	
	public static void setLocation(float x ,float y){
		//this.x = x;
		init_x = x;
		init_y = y;
		//this.y = y;
	}
	
	private void getBitmapSource(){
		switch(index){     
			case 1:{
				bar_header = BitmapFactory.decodeResource(getResources(), R.drawable.xiong_header);
				break;
			}
			case 2:{
				bar_header = BitmapFactory.decodeResource(getResources(), R.drawable.niu_header);
				break;
			}
			case 3:{
				bar_header = BitmapFactory.decodeResource(getResources(), R.drawable.ji_header);
				break;
			}
			case 4:{
				bar_header = BitmapFactory.decodeResource(getResources(), R.drawable.tu_header);
				break;
			}
			case 5:{
				bar_header = BitmapFactory.decodeResource(getResources(), R.drawable.zhu_header);
				break;
			}
			case 6:{
				bar_header = BitmapFactory.decodeResource(getResources(), R.drawable.yang_header);
				break;
			}
			default:break;
		}
	}
	
	

	public Bitmap draw(){
		return bar_header;
	}

	public int getIndex() {
		return this.index;
	}

	public void setDistance(int runDistance, int totalDistance, float totalwidth) {
		float percent = (float)runDistance / (float)totalDistance;
		Log.d("Distance",String.valueOf(percent));
		x = percent*totalwidth + init_x;
		y = init_y;
	}
	
}
